package com.itheima.static_case.Demo2;

import java.util.Random;

public class CreateCode {
    // 生成验证码
    public static String createCheckCode(int length) {
        String chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKMNOPQRSTUVWXYZ";

        String code = "";

        Random r = new Random();
        for (int i = 0; i < length; i++) {
            int index = r.nextInt(chars.length());
            code += chars.charAt(index);
        }

        return code;
    }
}
